
package com.feib.soeasy.dao;

import java.util.Date;

import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.feib.soeasy.model.Group;
import com.feib.soeasy.model.Payment;
import com.feib.soeasy.model.UploadFile;
import com.feib.soeasy.pagination.PaginatedList;


/**
 * @title (#)PaymentDaoTester.java<br>
 * @description <br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/11/18 create by Jimmy Liu<br>
 */
public class PaymentDaoTester {

    private static ApplicationContext context;

    private static PaymentDao paymentDao;
    
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @BeforeClass
    public static void runBeforeClass()
    {
        context = new FileSystemXmlApplicationContext(new String[] {
                        "src/main/webapp/WEB-INF/spring/applicationContext-config.xml"
                        , "src/main/webapp/WEB-INF/spring/applicationContext-dao.xml"
                        , "src/main/webapp/WEB-INF/spring/applicationContext-hibernate.xml"
        });

        paymentDao = (PaymentDao) context.getBean("paymentDao");

    }
    

    @Test
    public void queryPaginationByPayment()
    {
        Payment payment = new Payment();
        Group group = new Group();
        group.setGroupPk(new Long(1));
        payment.setGroup(group);
        
        UploadFile uploadFile = new UploadFile();
        uploadFile.setUploadFilePk(new Long(1));
        uploadFile.setCreatedBy("Jimmy");
        payment.setUploadFile(uploadFile);
        
        Date payDueFrom = null;
        Date payDueTo = null;
        PaginatedList<Payment> paginationConfig = new PaginatedList<Payment>();
        
        PaginatedList<Payment> queryResult=  paymentDao.queryPaginationByPayment(payment, payDueFrom, payDueTo, paginationConfig);
        
        logger.info(queryResult.toString());
    }
}
